$(document).ready(function () {
	var oTable = $('#example').dataTable({
		"bProcessing": false,
		"bServerSide": false,
		"bFilter": true,
		"bJQueryUI": true,
		"bSort": true,
		"bInfo":false,
		"bPaginate": false,
        "iDisplayLength": 20
	});
	
	$("#example_wrapper .fg-toolbar:last").html($(".hide-paginate").html());
	
	$("#check_all").click(function() {
		$("#example tbody tr").each(function(n,element){
			var chbox = '#categ_' + $(element).attr('id');
			$(element).addClass('row_selected');
			$(chbox).attr('checked', true);
		});
	});
	
	$("#uncheck_all").click(function() {
		$("#example tbody tr").each(function(n,element){
			var chbox = '#categ_' + $(element).attr('id');
			$(element).removeClass('row_selected');
			$(chbox).attr('checked', false);
		});
	});
	
	$("#example td input[type=checkbox]").click(function () {
		if ($(this).is(':checked')) {
			$(this).parents("tr").addClass('row_selected');
		} else {
			$(this).parents("tr").removeClass('row_selected');
		}
		
	});
	
	$("#multiple_controls input").click(function() {
		ctrl_name = $(this).attr('name');
		if (ctrl_name != 'check_all' && ctrl_name != 'uncheck_all')
			multiple_action(ctrl_name);
	});
	
});
